
	.code16
	// .extern __puts
	// .extern clear_screen
	.global	_start
_start:
	nop
	cli
	in	$0x92, %al
	or	$0x2, %al
	out	%al, $0x92
	sti
	
	mov	%cs, %ax
	mov	%ax, %ds
	mov	%ax, %ss
	mov	%ax, %es
	mov	%ax, %fs
	mov	%ax, %gs
	mov	$0x7c00, %sp

	call 	clear_screen
	
	lea	msg,  %si
	call	__puts
.1:
	jmp	.1

	ret

	/* 打印字符串 */
__puts:
	pusha
	xor	%bh, %bh
.loop:
	lodsb
	test	%al, %al
	jz	.done
	movb	$0x0e, %ah
	int	$0x10
	jmp	.loop
.done:	
	popa
	ret


/* 将 al 打印出来 */
__putc:
	push	%bx
	push	%ax
	xor	%bh, %bh
	movb	$0x0e, %ah
	int 	$0x10
	pop	%ax
	pop	%bx
	ret

__println:
	push 	%si
	mov	$13, %al
	call	__putc
	mov	$10, %al
	call	__putc
	pop	%si
	ret


/* clean screen */
clear_screen:
	pusha
	mov	$0x0600, %ax
	xor	%cx, %cx
	xor	$0x0f, %bh
	mov	$24, %dh
	mov	$79, %dl
	int 	$0x10

set_position:
	mov	$2, %ah
	mov	$0, %bh
	mov	$0, %dx
	int 	$0x10
	popa
	ret


msg:	
.asciz	"hello, kernel"


.org	510
.word	0xaa55
